package com.ldg.rmq.test;

import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.time.LocalDateTime;

/**
 * @Author: Liudao
 * @Date: 2022-09-28-0:38
 * @Description:
 */
@SpringBootTest
public class testproducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    /**
     * 1. 发送direct直连消息
     */
    @Test
    public void test01(){
        rabbitTemplate.convertAndSend("bnz","这是我的第一个消息，当前时间：" + LocalDateTime.now());
    }

    /**
     * 2. 发送fanout消息
     */
    @Test
    public void test02(){
        rabbitTemplate.convertAndSend("shenzhen-area","","正在发送fanout消息！");
    }

    /**
     * 3. 发送topic消息（以goods开头的消息）
     */
    @Test
    public void test03(){
        rabbitTemplate.convertAndSend("forbooks","goods.#","发送以goods开头的消息！");

    }

    /**
     * 4. 发送topic消息（以log结尾的消息）
     */
    @Test
    public void test04(){
        rabbitTemplate.convertAndSend("forbooks","#.log","发送以log结尾的消息！");

    }

    /**
     * 5. 发送topic消息（以goods开头和log结尾的消息）
     */
    @Test
    public void test05(){
        rabbitTemplate.convertAndSend("forbooks","goods.log","发送以goods开头和以log结尾的消息！");

    }
}
